package gdut.jmxywz.action;


import gdut.jmxywz.been.Prize;
import gdut.jmxywz.util.PageModel;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;


@SuppressWarnings("serial")
public class PrizeStatisticsAction extends BaseAction{
	
     private Prize prize;
     private String winner;		/*获奖者*/
     private String itemName;  /*项目名称*/
	 private PageModel pageModel;
	 private String awardType;  /*奖项级别*/
	 private String step;   /*奖项等级*/
	 private int prizeId;   /*获奖项目id*/
	 private String endTime;
	 private String stratTime;
	 private int currentPage=1;
		
	private int pageSize=5;

		
	 /***************show*****************/
		public String show()throws Exception{
			
			String hql=" from Prize where 1=1";
			hql = hql +" order by prizeId desc,winner desc";
			pageModel=this.getCommonService().findPage(hql, null, currentPage, pageSize,null,"");	
			return SUCCESS;
		}
		
		
		
		
		/***************详细*****************/
		public String detail() throws Exception {
			// TODO Auto-generated method stub
			System.out.println("******************");
			
			prize=(Prize)this.getCommonService().findByIntId(prizeId, "gdut.jmxywz.been.Prize");
			
			System.out.println("******************");
			if(prize==null)
				return "error";
			else
				return SUCCESS;
		}
		
		/**************查询****************/
		public String findByHql() throws Exception {
			System.out.println("***********");
			System.out.println(winner);
			System.out.println(itemName);
			System.out.println(awardType);
			System.out.println(step);
			try{
			SimpleDateFormat   sdf   =   new   SimpleDateFormat( "yyyy-MM-dd "); 
			System.out.println(stratTime+"``````````");
			Date   startTime1=sdf.parse(stratTime);                     
			Date   endTime1=sdf.parse(endTime);
			System.out.println("%%%%%%%%%%%%%%%%%%");
			System.out.println(stratTime);
			System.out.println(startTime1);
			System.out.println("%%%%%%%%%%%%%%%%%%");
			}
			catch(java.text.ParseException e){
				e.printStackTrace();
				
			}
			
			
			
			String hql=" from Prize  where 1=1";
			if(null!=winner&&!("".equals(winner))){           
				hql = hql+" and winner like '%"+winner+"%'  ";
			}
			if(null!=itemName&&!("".equals(itemName))){           
				hql = hql+" and itemName like '%"+itemName+"%'  ";
			}
			if(null!=awardType&&!("".equals(awardType))){           
				hql = hql+" and awardType like '%"+awardType+"%'  ";
			}
			if(null!=step&&!("".equals(step))){           
				hql = hql+" and step like '%"+step+"%'  ";
			}
			
			pageModel=this.getCommonService().findPage(hql, null, currentPage, pageSize,null,"");
			System.out.println(pageModel.getList().size());
			return SUCCESS;
		}




		public Prize getPrize() {
			return prize;
		}




		public void setPrize(Prize prize) {
			this.prize = prize;
		}




		public String getWinner() {
			return winner;
		}




		public void setWinner(String winner) {
			this.winner = winner;
		}




		public String getItemName() {
			return itemName;
		}




		public void setItemName(String itemName) {
			this.itemName = itemName;
		}




		public PageModel getPageModel() {
			return pageModel;
		}




		public void setPageModel(PageModel pageModel) {
			this.pageModel = pageModel;
		}




		public int getPrizeId() {
			return prizeId;
		}




		public void setPrizeId(int prizeId) {
			this.prizeId = prizeId;
		}




		public int getCurrentPage() {
			return currentPage;
		}




		public void setCurrentPage(int currentPage) {
			this.currentPage = currentPage;
		}




		public int getPageSize() {
			return pageSize;
		}




		public void setPageSize(int pageSize) {
			this.pageSize = pageSize;
		}




		public String getAwardType() {
			return awardType;
		}




		public void setAwardType(String awardType) {
			this.awardType = awardType;
		}




		public String getStep() {
			return step;
		}




		public void setStep(String step) {
			this.step = step;
		}




		public String getEndTime() {
			return endTime;
		}




		public void setEndTime(String endTime) {
			this.endTime = endTime;
		}




		public String getStratTime() {
			return stratTime;
		}




		public void setStratTime(String stratTime) {
			this.stratTime = stratTime;
		}


	
	
	    
	    

		
		
		
		
		
		
		
	
}
